Classification of mental workload using brain connectivity and machine learning on electroencephalogram data

Mental workload refers to the cognitive effort required to perform tasks, and it is an important factor in various fields, including system design, clinical medicine, and industrial applications. In this paper, we propose innovative methods to assess mental workload from EEG data that use effective brain connectivity for the purpose of extracting features, a hierarchical feature selection algorithm to select the most significant features, and finally machine learning models. We have used the Simultaneous Task EEG Workload (STEW) dataset, an open-access collection of raw EEG data from 48 subjects. We extracted brain-effective connectivities by the direct directed transfer function and then selected the top 30 connectivities for each standard frequency band. Then we applied three feature selection algorithms (forward feature selection, Relief-F, and minimum-redundancy-maximum-relevance) on the top 150 features from all frequencies. Finally, we applied sevenfold cross-validation on four machine learning models (support vector machine (SVM), linear discriminant analysis, random forest, and decision tree). The results revealed that SVM as the machine learning model and forward feature selection as the feature selection method work better than others and could classify the mental workload levels with accuracy equal to 89.53% (± 1.36).


Participants and EEG recording
We utilized the Simultaneous Task EEG Workload (STEW) dataset, an open-access collection of raw EEG data from 48 male subjects who participated in a multitasking workload experiment utilizing the SIMKAP multitasking test.The SIMKAP multitasking assessment involves participants in identifying and marking identical items across two panels, all while answering auditory questions that vary in type, such as arithmetic, comparison, or data retrieval.Certain auditory tasks may necessitate delayed responses, prompting individuals to monitor a clock positioned in the upper right corner.This multitasking segment follows a predetermined sequence of questions 34 .By focusing solely on male participants, the dataset minimizes variability arising from gender-related physiological differences that could impact EEG data collection and analysis.This approach allows for a more controlled examination of mental workload patterns and EEG responses, particularly in multitasking scenarios like those assessed in the SIMKAP experiment.The experiment consisted of two stages: 1. Information was gathered for 2.5 min when the participants were not engaged in any activity, referred to as 'low' MWL. 2. The participants took the SIMKAP test while their brain activity was monitored, and the last 2.5 min were considered the high MWL condition.
The EEG signals were obtained using the Emotiv EPOC EEG headset, featuring a 16-bit A/D resolution, and 128 Hz sampling frequency.Also, 14 channels including AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, and AF4 based on the 10-20 international system, in addition, CMS and DRL were as reference channels.The STEW dataset is valuable for studying multitasking workload and analyzing brain activity during different cognitive tasks.Researchers can use this dataset to develop and evaluate algorithms and models for MWL classification and prediction.

Preprocessing
We implemented the preprocessing pipeline recommended in the database-providing paper 34 .The pipeline involved: 1. High-pass filtering of the raw data at 1 Hz to filter out low frequency noise that can come from sources such as movement of the head and electrode wires, perspiration on the scalp, or slow drifts in the EEG signal over many seconds 2. Removing line noise which is caused by electrical equipment, such as power lines, that emit electromagnetic fields that interfere with the EEG signal 3. Performing Artifact Subspace Reconstruction (ASR) to automatically detect and remove unusual noise or artifacts from EEG signals 4. Re-reference the data to average to transform the data from a fixed or common reference to an 'average reference, ' which is advocated by some researchers, especially when the electrode montage covers nearly the whole head The application of ASR was emphasized due to the presence of large amplitude artifacts in the data.ASR is a non-stationary method to remove large-amplitude artifacts 35 .The preprocessing was conducted using the EEGLAB toolbox in MATLAB software (version 2019a).

Effective connectivity
Effective connectivity refers to the directional or unequal dependencies between distinct brain regions 36 .The primary technique for assessing effective connectivity is Granger causality (GC), which can be calculated within the frequency domain.To accomplish this, it is necessary to estimate the parameters of a Multi-Variable Auto-Regressive (MVAR) model for each individual signal dataset.Two crucial parameters for estimating the MVAR model from EEG signals are the window length and the model order.The window length is determined using the Variance-Ratio Test to maintain the stationarity of EEG signals.Subsequently, the estimated model is validated based on the whiteness of residuals, consistency percentage, and stability, and is chosen based on the Akaike Information Criterion (AIC).For a set of M channels of EEG data with lengths of T, denoted as X = {x_1; x_2;… ;x_T}, the MVAR process of order p is represented as follows 37 : where v represents an (M × 1) vector comprising intercept terms, denoted as matrices of model coefficients, and u t signifies a white noise process characterized by a zero mean and a non- singular covariance matrix Σ.
Rearranging terms results in: where A k = −A k and A 0 = −I.
After applying the Fourier transform to both sides: where By multiply Eq. ( 4) at A(f ) −1 and rearrange terms we have: where X f is the (M × M) spectral matrix of the multivariate process, U(f ) is a random sinusoidal shocks matrix and H f is the transfer matrix of the system.The spectral density matrix of the process is determined as follows: The matrices of S f , A(F) and H(f ) are utilized to establish various metrics of effective connectivity.dDTF explicitly captures directional interactions between brain regions, distinguishing between driving and response regions.This directional information is valuable for understanding the flow of information within neural networks.Also, dDTF allows for frequency-specific analysis of directed connectivity, providing insights into how different frequency bands contribute to information processing within the brain.This can be particularly useful in studying cognitive processes that are associated with specific frequency ranges.In addition, dDTF has proven efficacy in neuroscience investigations 31,3237,38 .
The calculation of dDTF from channel j to channel i at frequency f is determined by the following equation: (1) where H(f) is the transfer matrix of the system at a specific frequency and S(f) is the spectral density matrix.We extract five frequency bands for the dDTF measure by averaging the frequency spectrum as follows: delta (2-4), theta (4-8), alpha (8-13), beta (13-32), and gamma (32-50).All steps for dDTF measurement are done in MATLAB software by the Source Information Flow Toolbox (SIFT) version 0.1a 36 .

Feature Selection
Feature selection plays a crucial role in the interpretability of machine learning models.By carefully choosing which features to include in the model, researchers and practitioners can enhance the understanding of how the model makes predictions.In the context of MWL assessment from EEG data, feature selection is essential for understanding the relationship between brain regions and MWL assessment.By selecting the most relevant EEG features, researchers can better understand the underlying mechanisms of mental workload and provide more accurate and interpretable models.The removal of less important features can help enhance the performance of classification tasks.In order to distinguish between high-MWL and lo-MWL groups, a series of steps were followed.Initially, one-seventh of the data was set aside for testing.Subsequently, the area under the curve (AUC) for each neural activity flow in every band was calculated using LDA.The AUC-ROC value was derived from the mean values of all cross-validation sets, serving as a valid measure of the model's performance in a generalized setting.Following this, the top 30 connections from each frequency band with the highest AUC were selected which made the top 150 features among five frequency bands based on the AUC of each feature, and feature selection algorithms were subsequently applied.This process was designed to leverage neural activity flow features in each band to differentiate between high-MWL and lo-MWL, with a specific focus on the connections exhibiting the highest AUC values.Some popular feature selection algorithms include forward feature selection, minimum-redundancy-maximum-relevance (mRMR), and Relief-F which we have used in this paper.Forward Feature Selection is a stepwise feature selection method that starts with an empty feature set and iteratively adds one feature at a time based on the classifier performance.The process begins by evaluating the individual predictive power of each feature and selecting the best feature.Subsequently, additional features are sequentially added, with each subsequent feature chosen to maximize the improvement in model performance 39 .mRMR algorithm selects features based on their individual and combined predictive power, aiming to build models that capture the most important aspects of the data.It focuses on reducing redundancy and increasing relevance, ensuring that the selected features are both relevant to the problem and non-redundant to each other 40,41 .Relief-F is an unsupervised feature selection method that evaluates the importance of features based on their ability to distinguish between different classes.It measures the decrease in class separation (distance) between the closest neighbors of different classes when a feature is removed.The features with the highest decrease in class separation are selected as the most relevant features 42,43 .

Classification
In this paper, we've used four classifiers for data classifications which are SVM, LDA, Decision tree (DT), and Random forest (RF).SVM is a supervised machine learning model used for classification and regression tasks.It works by finding a hyperplane that separates the data points with the largest margin.SVM is particularly useful for handling both linear and nonlinear input spaces and can be more accurate than other algorithms in certain cases 44 .LDA is an algorithm used for dimensionality reduction and data visualization.It is a probabilistic model that aims to find a linear combination of input features that can maximize the separation between different classes.LDA is commonly used in various applications, such as sentiment analysis and spam detection 45 .A decision tree in machine learning is a supervised learning algorithm that creates models for classification and regression tasks.It uses a tree-like structure where each internal node represents a decision based on an attribute, leading to leaf nodes that represent outcomes.Decision trees are interpretable and widely used due to their simplicity and effectiveness in predicting values based on input features 46 .RF is an ensemble learning method used for both classification and regression tasks.It works by constructing multiple decision trees and combining their predictions to improve overall accuracy.RF is known for its simplicity, scalability, and performance in various applications 47 .

Statistical analysis
In our research, we have utilized k-fold cross-validation, a statistical method commonly used in machine learning to estimate the skill of a model.A cross-validation procedure is used to assess the effectiveness of machine learning models, and it can also be used to evaluate a model if there is insufficient data.For cross-validation to be performed, a portion of the training data must be set aside for evaluation later.We partitioned the data into k equally sized segments and then performed k iterations of training and validation.During each iteration, one of the k segments was held out as the test set, while the model was trained on the remaining data.This process was repeated for each segment, and the performance of the model was evaluated and averaged over the k iterations.
After conducting a trial-and-error analysis, it was determined that 7 is the optimal value for k.Further analysis was based on the results of the sevenfold cross-validation.The flowchart of the proposed method is provided in Fig. 1.In addition, we applied AUC to selecting the most important connections.The AUC measure, commonly used in evaluating the performance of binary classification models, does not rely on specific assumptions about the underlying data distribution.Instead, it assesses the ability of a classifier to distinguish between positive and negative instances across all possible decision thresholds.However, while AUC itself does not make assumptions about the data, its interpretation can be influenced by certain factors related to the classification problem and the data being analyzed.AUC assumes that the observations used to evaluate the classifier are independent of each other.Violations of this assumption, such as autocorrelation or clustering of observations, can potentially bias the AUC estimate.In addition, AUC is designed for binary classification tasks where there are two distinct classes

Results
The EEG data from each subject's 14 channels were pre-processed using the EEGLAB toolbox in MATLAB software (version 2019a).A sample of data before and after the preprocessing pipeline is provided in Fig. 2. Subsequently, we computed the effective connectivity across all EEG data utilizing dDTF.The dDTF connectivities were derived from sequential 6-s segments of data from 14 channels for each subject across 5 frequency bands.Specifically, a 6-s window was slid along the EEG signals with a step size of 4 s. Figure 3 shows some samples of the dDTF image extracted from 'high' and 'low' MWL related to subject 16 for each frequency band.Horizontal axes and vertical axes represent channels.Considering 150 s of EEG signals, 6-s as window size, and 4-s as window step, we achieved 37 dDTF matrices per EEG data.Subsequently, the AUC values for each directed connection were computed based on their respective dDTF values.These AUC values are then independently ranked, and the top 30 connections are identified according to their AUC values (Table 1, Fig. 4).In addition, Table 3 provides the number of connections within each region.Based on this table, the frontal lobe has the highest number of neural connections.The classification results and computational efficiency of four machine learning models (SVM, LDA, RF, and DT) for each frequency band and a combination of the top 30 AUC-based features from all bands (top 150) are shown in Table 4.The SVM and DT models demonstrated the best and weakest performance respectively, as indicated in Table 4.In addition, the top 150 features have the highest accuracy, specificity, sensitivity, and F1-measure in all models.Based on the information provided in Table 4, the RF model was the most time-consuming of the four investigated models, while the LDA model was the least time-consuming.We applied a hierarchical feature selection in this paper.So, after selecting 150 top features based on AUC, we used three different feature selection algorithms in parallel including Relief-F, forward feature selection, and mRMR.According to Table 5, the forward feature selection's results were better than others and the SVM model could achieve 89.53% accuracy on 41 features that were selected based on the forward feature selection algorithm.The 41 selected features based on the forward feature selection are provided in Table 6.

Discussion
In this study, we investigated a new method for the classification of low MWL and high MWL from 14-channel EEG data in 48 participants.In the proposed model we extracted features from EEG signals by the brain's effective connectivity.In this state, we had 37 matrices with dimensions of 14*14 for each EEG data.For the purpose of extracting the most significant connectivities at the first step, we calculated AUC for all connectivities and selected the top 30 connectivities with high AUC scores which provided 150 features in 5 frequency bands.
According to Tables 2 and 3, the most significant connectivities in order to differ between high MWL and low MWL classes are from the frontal lobe.This result is in line with the findings of previous studies [48][49][50] , who also reported similar outcomes.Table 4 provides a comparison between all features in each frequency band and the top 150 selected features.It revealed that the best accuracy achieved from the top 150 selected features on SVM is equal to 88.96%.At the next step of the feature selection, we applied three feature selection methods on the top 150 features which were forward feature selection, Relief-F, and mRMR.Finally, we used four machine learning algorithms, SVM, LDA, DT, and RF in sevenfold cross-validation to classify the data.Using cross-validation in our research provided a more accurate estimate of out-of-sample accuracy, prevented overfitting, and allowed for more efficient use of data.After the next layer of feature selection, the number of selected features decreased and Table 5 provides a comparison between the accuracy of each algorithm's results which indicates that the forward feature selection algorithm was most successful among all three feature selection algorithms.Forward feature selection selected the 41 most significant features that are provided in Table 6 and these selected features could achieve an accuracy of 89.53% in SVM which was even better than the accuracy of the top 150 selected features based on AUC.The proposed framework to classify MWL from EEG data could achieve high accuracy and be in the top range of accuracy between other studies that used machine learning methods to classify MWL into two classes (Table 7).By leveraging brain effective connectivity analysis through dDTF and employing hierarchical feature selection alongside various machine learning models, also with finding and visualizing most important regions in brain for MWL assessment by calculating the brain connectivities, the research significantly has advanced the field of MWL assessment.This approach not only refines the precision of MWL assessment but also contributes to the  www.nature.com/scientificreports/development of more robust and interpretable models for MWL assessment.In this research, we had some limitations, especially in the dataset.We used the STEW dataset which is a well-known dataset in this field, but this dataset has some constraints such as the low number of participants and gender limitations because the dataset has only male participants and these may affect the generalizability of the findings to the broader population.In addition, the current study used just four machine learning algorithms, but future researchers in this field can try to apply more machine learning algorithms or even deep learning models.Future studies could benefit from expanding the dataset to include a more diverse and representative sample, encompassing participants of different genders and demographics.This would improve the robustness and applicability of the research findings.
In addition, researchers can explore a wider range of machine learning algorithms beyond the four used in the current study.Incorporating more algorithms, including advanced deep learning models, can provide a more comprehensive analysis and potentially uncover additional insights from the data.

Conclusion
In this paper, we proposed a framework for classifying MWL into two classes.To reach this purpose, we used effective brain connectivity as the feature extraction technique and applied four machine learning algorithms including SVM, LDA, RF, and DT.In addition, we investigated a hierarchical feature selection method.In the first step, we extracted the top 30 features based on AUC in each frequency band and then applied three feature selection algorithms which were forward feature selection, Relief-F, and mRMR.The results of this study suggest that machine learning algorithms especially SVM and the proposed framework for feature extraction and hierarchical feature selection can classify MWL levels from EEG data with high accuracy (89.53%).In future investigations, deep learning models can be utilized to construct a robust framework for evaluating MWL through the use of effective brain connectivity images.Table 2.An overview of electrodes across all frequency bands is presented.On the left, the electrode names and the number of originating connections are listed, while on the right, the electrode names and the number of connections to which the connections end are provided.

Figure 1 .
Figure 1.The flowchart of the proposed method.In this method firstly we preprocessed the raw EEG data, then calculated the effective connectivity with the dDTF index in 5 frequency bands.In the next step, the top 30 features based on AUC in each frequency band were calculated and then we applied three feature selection algorithms on them.Finally, we classified the final selected features from each feature selection algorithm.

Figure 2 .
Figure 2. EEG signal before and after preprocessing.The top panel shows the raw EEG signal, while the bottom panel shows the same signal after preprocessing.The preprocessing steps applied to the signal are described in the Methods section.

Figure 3 .
Figure 3.The effective brain connectivity matrices calculated by dDTF for subject-16 in delta, theta, alpha, beta, and gamma bands.

Figure 4 .
Figure 4. Based on the AUC values, the top 30 neural activity patterns that demonstrate differences in propagation between the high MWL and low MWL groups are depicted.In this illustration, nodes represent electrodes in the 10-20 system, the edges indicate connection between channels, and the edges' color represent the AUC values.

Table 1 .
Based on the AUC values of high-MWL and low-MWL groups, the 30 most significant neural activity flows in the delta, theta, alpha, beta, and gamma bands are as follows.

Table 3 .
A comprehensive overview of the connections across different frequency bands in the different regions of the brain.The table presents the number of connections within each region, including the central, frontal, occipital, parietal, and temporal lobes among five brain frequency bands (Delta, Theta, Alpha, Beta, and Gamma).The 'From' columns indicate the number of connections originating from a specific region, while the 'To' column shows the number of connections ending in the specified region.For instance, there are 19 connections from the frontal lobe in the alpha frequency band, and in total from all five frequency bands there are 73 connections that originated from the frontal lobe.The highest number of connections among all lobes and frequency bands in each group ("From" and "To") are bold.Values of significant regions are in[italic].

Table 4 .
A comparison of SVM, LDA, RF, and DT classification results in the delta, theta, alpha, beta, gamma, top150, and top30 bands.Significant values are in bold.

Table 5 .
A comparison of SVM, LDA, RF, and DT classification results in the delta, theta, alpha, beta, and gamma bands using mRMR, Relief-F and forward feature selection using features from all frequency bands.Significant values are in[bold].

Table 6 .
Top 41 features selected among top-150 features based on forward feature selection and SVM model.

Table 7 .
Comparison between previous studies which proposed a framework to assess MWL from STEW dataset with two class by machine learning methods.